package com.sk.bilibili.interceptor;

/**
 * @author 邵康
 * @date 2021/12/18 15:07
 * 插件只需要注入容器即可 例如分页插件
 */

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.handler.PostValueHandler;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;

@Component
@Intercepts(@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class,
        RowBounds.class, ResultHandler.class}))
public class PostValueInterceptor extends BaseInterceptor<PostValueHandler> {

    @Override
    protected void handleValue(PostValueHandler handler, Object res) {
        handler.postHandle(res);
    }

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        Object res = invocation.proceed();
        handleValue(res);
        return res;
    }

}
